package com.jinke.uang.ui.activity.personal;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.jinke.uang.R;
import com.jinke.uang.base.BaseNetActivity;
import com.jinke.uang.common.RouterMap;
import com.jinke.uang.common.NoDoubleClickListener;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 登录状态展示页的
 */
@Route(path = RouterMap.REGISTER_RESULT)
public class LoginStatusActivity extends BaseNetActivity {


    @BindView(R.id.topBack)
    ImageView topBack;
    @BindView(R.id.topText)
    TextView topText;
    @BindView(R.id.tvHint)
    TextView tvHint;
    @BindView(R.id.tvGo)
    TextView tvGo;

    //1 注册成功 2 忘记密码成功
    public int resultType;
    public String userame;

    @Override
    protected void initViews() {
        ButterKnife.bind(this);
        resultType = getIntent().getIntExtra("result_type", 0);
        userame = getIntent().getStringExtra("user_name");
    }


    @Override
    protected void onUIReady() {
        if (1 == resultType) {
            topText.setText(R.string.result_register);
            tvHint.setText(R.string.result_register_success);
            tvGo.setText(R.string.result_go_login);
        } else if (2 == resultType) {
            topText.setText(R.string.forget_title);
            tvHint.setText(R.string.result_forget_success);
            tvGo.setText(R.string.result_go_login);
        }
        topBack.setOnClickListener(viewclick);
        tvGo.setOnClickListener(viewclick);
    }

    @Override
    protected int getContentResId() {
        return R.layout.activity_register_result;
    }

    @Override
    public String getPageTitle() {
        return null;
    }

    @Override
    protected int getResId() {
        return 0;
    }

    /**
     * 点击信息
     */
    private NoDoubleClickListener viewclick = new NoDoubleClickListener() {
        @Override
        public void onNoDoubleClick(View v) {
            super.onNoDoubleClick(v);
            switch (v.getId()) {
                case R.id.topBack:
                    finish();
                    break;
                case R.id.tvGo:
                    if (1 == resultType || 2 == resultType) {
                        ARouter.getInstance().build(RouterMap.LOGIN_PAGE).withString
                                (LoginActivity.USER_NAME, userame).navigation();
                    }
                    break;
                default:
                    break;
            }
        }
    };
}
